﻿using System;

namespace FDEE.Model
{
    /// <summary>
    /// PTM大类墩柱
    /// </summary>
    internal abstract class CPTMBase : ColumnBase
    {
        protected int Width, Length, Radius;
        protected double LenUpper, LenLower;//上下部加密长度
        protected RebarTendonDistribute MainLBarDistribute, AddLBarDistribute;// 顺桥向主筋A截面、加强筋配置规律
        protected RebarTendonDistribute MainWBarDistribute, AddWBarDistribute;// 横桥向主筋A截面、加强筋配置规律
        protected RebarTendonDistribute MainLBarDistributeB, AddLBarDistributeB;// 顺桥向主筋B截面、加强筋配置规律
        protected RebarTendonDistribute MainWBarDistributeB, AddWBarDistributeB;// 横桥向主筋B截面、加强筋配置规律
        protected RebarTendonDistribute MainLBarDistributeC, AddLBarDistributeC;// 顺桥向主筋C截面、加强筋配置规律
        protected RebarTendonDistribute MainWBarDistributeC, AddWBarDistributeC;// 横桥向主筋C截面、加强筋配置规律

        /// <summary>
        /// PTM类墩柱基类
        /// </summary>
        /// <param name="typeName"></param>
        /// <param name="pierNumber"></param>
        /// <param name="st"></param>
        /// <param name="ww">截面横桥向宽度</param>
        /// <param name="ll">截面顺桥向长度</param>
        /// <param name="hh">墩净高</param>
        /// <param name="rr">截面圆倒角半径</param>
        /// <param name="up">上部加密长度</param>
        /// <param name="low">下部加密长度</param>
        /// <param name="numRebarL">顺桥向外侧均布主筋个数</param>
        /// <param name="numRebarW">横桥向外侧均布主筋个数</param>
        /// <param name="mainDB">主筋直径</param>
        internal CPTMBase(string typeName, string pierNumber, eColumnType ct, eSubType st,
            int ww, int ll, int hh, int rr, double up, double low, eDB mainDB
            )
            : base(typeName, pierNumber, hh, ct,st, mainDB)
        {
            Width = ww;
            Length = ll;
            Radius = rr;
            LenUpper = up;
            LenLower = low;
        }

        public override void SetConcreteVolume()
        {
            double A = Width * 0.001 * (Length * 0.001 - 2 * Radius * 0.001) + 2 * (Width * 0.001 - 2 * Radius * 0.001) * Radius * 0.001 + Math.PI * Radius * 0.001 * Radius * 0.001;
            ConcreteVolumn = A * PierHeight*0.001;
        }


        /// <summary>
        /// 计算净墩高范围内箍筋数量
        /// </summary>
        /// <param name="UpperSpace">上部间距，默认100mm</param>
        /// <param name="MidSpace">正常间距，默认300mm</param>
        /// <param name="LowerSpace">下部间距，默认100mm</param>
        /// <returns></returns>
        internal int GetStirrupNum(int UpperSpace = 100, int MidSpace = 300, int LowerSpace = 100)
        {
            if ((PierHeight - LenLower - LenUpper) < 0)
            {
                throw new Exception("墩高配置错误");
            }
            double npts = Math.Round(LenLower / LowerSpace, 0, MidpointRounding.AwayFromZero) +
                Math.Round((PierHeight - LenLower - LenUpper) / MidSpace, 0, MidpointRounding.AwayFromZero) +
            Math.Round(LenUpper / UpperSpace, 0, MidpointRounding.AwayFromZero);
            return (int)npts+3;
        }



    }





}
